package com.aricksm.xuan.activity01;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/**
 * Created by xuan on 16/6/16.
 */
public class CallPhone extends Activity {

    Button callBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.callphone);

        callBtn = (Button) findViewById(R.id.callBtn);
        callBtn.setOnClickListener(new callBtnClick());
    }

    class callBtnClick implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            Log.e("call phone","dianji");

            EditText et = (EditText) findViewById(R.id.phoneNomber);
            String phoneNomber = et.getText().toString();
            Log.e("phone nomber",""+phoneNomber);

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel://"+phoneNomber));
            startActivity(intent);
        }
    }
}
